#include <iostream>
using namespace std;
const int N = 100010;
int n, m;
int a[N], s[N];
int main()
{
    scanf("%d %d", &n, &m);  //输入n长度的数组，求m次和
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);  //输入数组
    for (int i = 1; i <= n; i++)
        s[i] = s[i - 1] + a[i];  //前缀和
    while(m--)
    {
        int l,r;
        scanf("%d %d", &l,&r);  //输入左右边界
        printf("%d\n",s[r]-s[l-1]);  //求边界数组和
    }
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             